<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
require_once "Fdd.Exception.php";
require_once "Fdd.Config.php";
require_once "Fdd.Data.php";
require_once "Fdd.Encryption.php";
date_default_timezone_set("PRC");
class FddApi
{
    public static function registerAccount(FddAccount $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/account_register.api";
        try {
            $des = new FddEncryption();
            if(!$param->IsOpenIDSet()) {
                throw new FddException("缺少必填参数-open_id");
            }
            if(!$param->IsAccountTypeSet()) {
                throw new FddException("缺少必填参数-account_type");
            }
            $encArr = $param->GetValues();
            $encKey = array_keys($encArr);
            array_multisort($encKey);
            $enc = ["md5" => [], "sha1" => $encKey];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function getCompanyVerifyUrl(FddCertification $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/get_company_verify_url.api";
        try {
            if(!$param->IsCustomerIDSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsPageModifySet()) {
                throw new FddException("缺少必填参数-page_modify");
            }
            $des = new FddEncryption();
            $param->SetLegalName(NULL);
            $encArr = $param->GetValues();
            $encKey = array_keys($encArr);
            $encKey = array_diff($encKey, ["agent_id", "agent_id_front_path", "agent_mobile", "agent_name", "bank_card_no", "bank_id", "bank_name", "subbranch_name", "company_name", "credit_image_path", "credit_no", "legal_id", "legal_id_front_path", "legal_name", "legal_mobile", "m_verified_way", "agent_id_front_img", "authorization_file", "agent_id_back_path", "legal_id_back_path", "agent_id_back_img", "legal_id_back_img"]);
            array_multisort($encKey);
            $enc = ["md5" => [], "sha1" => $encKey];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function getPersonVerifyUrl(FddCertification $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/get_person_verify_url.api";
        try {
            if(!$param->IsCustomerIDSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsVerifiedWaySet()) {
                throw new FddException("缺少必填参数-verified_way");
            }
            if(!$param->IsPageModifySet()) {
                throw new FddException("缺少必填参数-page_modify");
            }
            $des = new FddEncryption();
            $encArr = $param->GetValues();
            $encKey = array_keys($encArr);
            $encKey = array_diff($encKey, ["ident_front_img", "ident_back_img"]);
            array_multisort($encKey);
            $enc = ["md5" => [], "sha1" => $encKey];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ApplyCert(FddCertification $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/apply_cert.api";
        try {
            if(!$param->IsCustomerIDSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsVerifiedSerialNo()) {
                throw new FddException("缺少必填参数-verified_serialno");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "verified_serialno"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function UploadSignature(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/add_signature.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsSignatureImgBase64()) {
                throw new FddException("缺少必填参数-signature_img_base64");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "signature_img_base64"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function UploadSignatureContent(FddSignatureContent $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/custom_signature.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsContent()) {
                throw new FddException("缺少必填参数-content");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["content", "customer_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function Uploaddocs(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/uploaddocs.api";
        try {
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsDoc_titleSet()) {
                throw new FddException("缺少必填参数-doc_title");
            }
            if(!$param->IsDoc_typeSet()) {
                throw new FddException("缺少必填参数-doc_type");
            }
            if(!$param->IsFileSet() && !$param->IsDoc_urlSet()) {
                throw new FddException("缺少必填参数-file、doc_url 二选一");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function UploadTemplate(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/uploadtemplate.api";
        try {
            if(!$param->IsTemplate_idSet()) {
                throw new FddException("缺少必填参数-template_id");
            }
            if(!$param->IsFileSet() && !$param->IsDoc_urlSet()) {
                throw new FddException("缺少必填参数-file、doc_url 二选一");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function GenerateContract(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/generate_contract.api";
        try {
            if(!$param->IsTemplate_idSet()) {
                throw new FddException("缺少必填参数-template_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsParameter_mapSet()) {
                throw new FddException("缺少必填参数-parameter_map");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $param->SetMsg_digest($des::ContractDigest($param));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ExtsignAuto(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/extsign_auto.api";
        try {
            if(!$param->IsTransaction_idSet()) {
                throw new FddException("缺少必填参数-transaction_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsDoc_titleSet()) {
                throw new FddException("缺少必填参数-doc_title");
            }
            if(!$param->IsClient_roleSet()) {
                throw new FddException("缺少必填参数-client_role");
            }
            if($param->IsPosition_typeSet()) {
                if($param->GetPosition_type() == 1 && !$param->IsYSet() && !$param->IsXSet() && !$param->IsPagenumSet()) {
                    throw new FddException("缺少必填参数- x 、y 、pagenum");
                }
                if($param->GetPosition_type() == 0 && !$param->IsSign_keywordSet()) {
                    throw new FddException("缺少必填参数- Sign_keyword");
                }
            }
            $pagenum = $param->GetPagenum();
            $x = $param->GetX();
            $y = $param->GetY();
            $SearchLocation = [["pagenum" => $pagenum, "x" => $x, "y" => $y]];
            $param->SetSignature_positions(json_encode($SearchLocation));
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            $param->SetDoc_title(urlencode($param->GetDoc_title()));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $param->SetMsg_digest($des::ExtsignDigest($param));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function Extsign(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/extsign.api";
        try {
            if(!$param->IsTransaction_idSet()) {
                throw new FddException("缺少必填参数-transaction_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsDoc_titleSet()) {
                throw new FddException("缺少必填参数-doc_title");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            $param->SetDoc_title(urlencode($param->GetDoc_title()));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $param->SetMsg_digest($des::ExtsignDigest($param));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ExtsignValidation(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/extsign_validation.api";
        try {
            if(!$param->IsTransaction_idSet()) {
                throw new FddException("缺少必填参数-transaction_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsDoc_titleSet()) {
                throw new FddException("缺少必填参数-doc_title");
            }
            if(!$param->IsReturn_urlSet()) {
                throw new FddException("缺少必填参数-return_url");
            }
            if(!$param->IsValiditySet()) {
                throw new FddException("缺少必填参数-validity");
            }
            if(!$param->IsQuantitySet()) {
                throw new FddException("缺少必填参数-quantity");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            $param->SetDoc_title(urlencode($param->GetDoc_title()));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $param->SetMsg_digest($des::ExtsignValiityDigest($param));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function QuerySignResult(FddQuerySignResult $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/query_sign_result.api";
        try {
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsTransaction_idSet()) {
                throw new FddException("缺少必填参数-transaction_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id", "customer_id", "transaction_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ViewContract(FddContractManageMent $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/viewContract.api";
        try {
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function GetUrl(FddContractManageMent $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/geturl.api";
        try {
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsValiditySet()) {
                throw new FddException("缺少必填参数-validity");
            }
            if(!$param->IsQuantitySet()) {
                throw new FddException("缺少必填参数-quantity");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => ["validity", "quantity"], "sha1" => ["contract_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function DownLoadContract(FddContractManageMent $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/downLoadContract.api";
        try {
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function GetContractHash(FddContractManageMent $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/getContractHash.api";
        try {
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ContractFiling(FddContractManageMent $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/contractFiling.api";
        try {
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ContractVerify(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/contract_verify.api";
        try {
            if(!$param->IsFileSet() && !$param->IsDoc_urlSet()) {
                throw new FddException("缺少必填参数-file、doc_url 二选一");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["doc_url"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function FindPersonCertInfo(FddCertification $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/find_personCertInfo.api";
        try {
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["verified_serialno"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function FindCompanyCertInfo(FddCertification $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/find_companyCertInfo.api";
        try {
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["verified_serialno"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function getFile(FddCertification $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/get_file.api";
        try {
            if(!$param->IsUUID()) {
                throw new FddException("缺少必填参数-uuid");
            }
            $des = new FddEncryption();
            $encArr = $param->GetValues();
            $encKey = array_keys($encArr);
            array_multisort($encKey);
            $enc = ["md5" => [], "sha1" => $encKey];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            header("location:" . $url . $des->ArrayParamToStr($input));
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function BeforeAuthsign(FddAuthSign $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/before_authsign.api";
        try {
            if(!$param->IsTransaction_idSet()) {
                throw new FddException("缺少必填参数-transaction_id");
            }
            if(!$param->IsAuth_typeSet()) {
                throw new FddException("缺少必填参数-auth_type");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsReturn_urlSet()) {
                throw new FddException("缺少必填参数-return_url");
            }
            if(!$param->IsNotify_urlSet()) {
                throw new FddException("缺少必填参数-notify_url");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => ["transaction_id"], "sha1" => ["customer_id"]];
            $param->SetMsg_digest($des::AuthSignDigest($param, $enc));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function GetAuthStatus(FddAuthSign $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/get_auth_status.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id"]];
            $param->SetMsg_digest($des::AuthSignDigest($param, $enc));
            $input = $param->GetValues();
            $res = self::https_request($url, $input);
            return $res;
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function CancelExtsignAutoPage(FddAuthSign $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/cancel_extsign_auto_page.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsReturn_urlSet()) {
                throw new FddException("缺少必填参数-return_url");
            }
            if(!$param->IsNotify_urlSet()) {
                throw new FddException("缺少必填参数-notify_url");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "notify_url", "return_url"]];
            $param->SetMsg_digest($des::AuthSignDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function QuerySignstatus(GeneralParam $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/query_signstatus.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id", "customer_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function BatchDownloadContract(FddContractManageMent $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/batch_download_contract.api";
        try {
            if(!$param->IsContract_idsSet()) {
                throw new FddException("缺少必填参数-contract_ids");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_ids"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ShortUrl(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/short_url.api";
        try {
            if(!$param->IsSource_urlSet()) {
                throw new FddException("缺少必填参数-source_url");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["expire_time", "source_url"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function PushShortUrlSms(SmsParam $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/push_short_url_sms.api";
        try {
            if(!$param->IsSource_urlSet()) {
                throw new FddException("缺少必填参数-source_url");
            }
            if(!$param->IsExpire_timeSet()) {
                throw new FddException("缺少必填参数-expire_time");
            }
            if(!$param->IsMobile()) {
                throw new FddException("缺少必填参数-mobile");
            }
            if(!$param->IsMessage_typeSet()) {
                throw new FddException("缺少必填参数-message_type");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["expire_time", "message_content", "message_type", "mobile", "sms_template_type", "source_url"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function SmsText(SmsParam $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/sms_text.api";
        try {
            if(!$param->IsMobile()) {
                throw new FddException("缺少必填参数-mobile");
            }
            if(!$param->IsMessage_typeSet()) {
                throw new FddException("缺少必填参数-message_type");
            }
            if($param->IsEncrypt_typeSet() && "0" == $param->GetEncrypt_type()) {
                $encrypt = new FddEncryption();
                $param->SetMobile($encrypt->encrypt($param->getMobile()));
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => ["mobile", "message_type", "message_content", "code", "encrypt_type"], "sha1" => []];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ComplianceContractReport(ComplianceContractReport $param, $timeOut = 6)
    {
        $url = FddConfig::FDDWitnessServer . "/api/compliance-contract-report";
        try {
            if(!$param->IsContractNumSet()) {
                throw new FddException("缺少必填参数-contractNum");
            }
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contractNum", "account"]];
            $param->SetMsgDigest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ViewTemplate(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/view_template.api";
        try {
            if(!$param->IsTemplate_idSet()) {
                throw new FddException("缺少必填参数-template_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function DownloadTemplate(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/download_template.api";
        try {
            if(!$param->IsTemplate_idSet()) {
                throw new FddException("缺少必填参数-template_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function TemplateDelete(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/template_delete.api";
        try {
            if(!$param->IsTemplate_idSet()) {
                throw new FddException("缺少必填参数-template_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function DownloadTemplateImgs(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/download_template_imgs.api";
        try {
            if(!$param->IsTemplate_idSet()) {
                throw new FddException("缺少必填参数-template_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function GetPdftemplateKeys(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/get_pdftemplate_keys.api";
        try {
            if(!$param->IsTemplate_idSet()) {
                throw new FddException("缺少必填参数-template_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function AddKeys(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/add_keys.api";
        try {
            if(!$param->IsContract_template_idSet()) {
                throw new FddException("缺少必填参数-contract_template_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function UploadTemplateDocs(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/upload_template_docs.api";
        try {
            if(!$param->IsContract_template_idSet()) {
                throw new FddException("缺少必填参数-contract_template_id");
            }
            if(!$param->IsFileSet()) {
                throw new FddException("缺少必填参数-file");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function GetDocStream(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/get_doc_stream.api";
        try {
            if(!$param->IsContract_template_idSet()) {
                throw new FddException("缺少必填参数-contract_template_id");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function FillPage(FddTemplate $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/fill_page.api";
        try {
            if(!$param->IsContract_template_idSet()) {
                throw new FddException("缺少必填参数-contract_template_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsDoc_titleSet()) {
                throw new FddException("缺少必填参数-doc_title");
            }
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["contract_id", "contract_template_id"]];
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function PersonVerifySign(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/person_verify_sign.api";
        try {
            if(!$param->IsTransaction_idSet()) {
                throw new FddException("缺少必填参数-transaction_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsNotify_urlSet()) {
                throw new FddException("缺少必填参数-notify_url");
            }
            if(!$param->IsPageModifySet()) {
                throw new FddException("缺少必填参数-page_modify");
            }
            if(!$param->IsVerified_notify_urlSet()) {
                throw new FddException("缺少必填参数-verified_notify_url");
            }
            if(!$param->IsVerifiedWaySet()) {
                throw new FddException("缺少必填参数-verified_way");
            }
            $des = new FddEncryption();
            $encArr = $param->GetValues();
            $encKey = array_keys($encArr);
            array_multisort($encKey);
            $enc = ["md5" => [], "sha1" => $encKey];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function BatchQuickSign(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/batch_quick_sign.api";
        try {
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsBatch_idSet()) {
                throw new FddException("缺少必填参数-batch_id");
            }
            if(!$param->IsSign_dataSet()) {
                throw new FddException("缺少必填参数-sign_data");
            }
            if(!$param->IsBatch_titleSet()) {
                throw new FddException("缺少必填参数-batch_title");
            }
            if(!$param->IsReturn_urlSet()) {
                throw new FddException("缺少必填参数-return_url");
            }
            if(!$param->IsNotify_urlSet()) {
                throw new FddException("缺少必填参数-notify_url");
            }
            if(!$param->IsPageModifySet()) {
                throw new FddException("缺少必填参数-page_modify");
            }
            if(!$param->IsVerified_notify_urlSet()) {
                throw new FddException("缺少必填参数-verified_notify_url");
            }
            if(!$param->IsVerifiedWaySet()) {
                throw new FddException("缺少必填参数-verified_way");
            }
            $param->SetSign_data(urlencode($param->GetSign_data()));
            $des = new FddEncryption();
            $encArr = $param->GetValues();
            $encKey = array_keys($encArr);
            array_multisort($encKey);
            $enc = ["md5" => [], "sha1" => $encKey];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function DocusignAcrosspage(DocusignAcrosspage $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/docusign_acrosspage.api";
        try {
            if(!$param->IsTransaction_idSet()) {
                throw new FddException("缺少必填参数-transaction_id");
            }
            if(!$param->IsContract_idSet()) {
                throw new FddException("缺少必填参数-contract_id");
            }
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["transaction_id", "contract_id", "customer_id"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function GotoBatchSemiautoSignPage(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/gotoBatchSemiautoSignPage.api";
        try {
            if(!$param->IsBatch_idSet()) {
                throw new FddException("缺少必填参数-batch_id");
            }
            if(!$param->IsBatch_titleSet()) {
                throw new FddException("缺少必填参数-batch_title");
            }
            if(!$param->IsSign_dataSet()) {
                throw new FddException("缺少必填参数-sign_data");
            }
            if(!$param->IsCustomer_idSet()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsReturn_urlSet()) {
                throw new FddException("缺少必填参数-return_url");
            }
            $param->SetSign_data(urlencode($param->GetSign_data()));
            $des = new FddEncryption();
            $enc = ["md5" => ["batch_id"], "sha1" => ["customer_id", "outh_customer_id"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::AuthSignDigest($param, $enc));
            $input = $param->GetValues();
            return $url . $des->ArrayParamToStr($input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ExtBatchSignAuto(FddSignContract $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/extBatchSignAuto.api";
        try {
            if(!$param->IsBatch_idSet()) {
                throw new FddException("缺少必填参数-batch_id");
            }
            if(!$param->IsBatch_titleSet()) {
                throw new FddException("缺少必填参数-batch_title");
            }
            if(!$param->IsSign_dataSet()) {
                throw new FddException("缺少必填参数-sign_data");
            }
            if(!$param->IsNotify_urlSet()) {
                throw new FddException("缺少必填参数-notify_url");
            }
            $des = new FddEncryption();
            $enc = ["md5" => ["batch_id"], "sha1" => ["sign_data"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::AuthSignDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function Authorization(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/authorization.api";
        try {
            if(!$param->IsCompany_id()) {
                throw new FddException("缺少必填参数-company_id");
            }
            if(!$param->IsPerson_id()) {
                throw new FddException("缺少必填参数-person_id");
            }
            if(!$param->IsOperate_type()) {
                throw new FddException("缺少必填参数-operate_type");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["company_id", "person_id", "operate_type"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function AuthorizeSignature(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/authorize_signature.api";
        try {
            if(!$param->IsCompany_id()) {
                throw new FddException("缺少必填参数-company_id");
            }
            if(!$param->IsPerson_id()) {
                throw new FddException("缺少必填参数-person_id");
            }
            if(!$param->IsOperate_type()) {
                throw new FddException("缺少必填参数-operate_type");
            }
            if(!$param->IsSignature_id()) {
                throw new FddException("缺少必填参数-signature_id");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["company_id", "operate_type", "person_id", "signature_id"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function FindSignatureAuthList(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/find_signature_auth_list.api";
        try {
            if(!$param->IsTypeSet()) {
                throw new FddException("缺少必填参数-type");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "signature_id", "type"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function QuerySignature(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/query_signature.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "signature_id"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function ReplaceSignature(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/replace_signature.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsSignature_id()) {
                throw new FddException("缺少必填参数-signature_id");
            }
            if(!$param->IsSignatureImgBase64()) {
                throw new FddException("缺少必填参数-signature_img_base64");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "signature_id", "signature_img_base64"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function RemoveSignature(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/remove_signature.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            if(!$param->IsSignature_id()) {
                throw new FddException("缺少必填参数-signature_id");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "signature_id"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function DefaultSignature(FddSignature $param, $timeOut = 6)
    {
        $url = FddConfig::FddServer . "/api/default_signature.api";
        try {
            if(!$param->IsCustomerId()) {
                throw new FddException("缺少必填参数-customer_id");
            }
            $des = new FddEncryption();
            $enc = ["md5" => [], "sha1" => ["customer_id", "signature_id"]];
            $param->SetApp_id(FddConfig::AppId);
            $param->SetTimestamp(date("YmdHis"));
            if(!$param->IsVSet()) {
                $param->SetV("2.0");
            }
            $param->SetMsg_digest($des::GeneralDigest($param, $enc));
            $input = $param->GetValues();
            return self::https_request($url, $input);
        } catch (FddException $e) {
            return ["result" => "error", "code" => 2001, "msg" => $e->errorMessage()];
        }
    }
    public static function https_request($url, $data = "", $type = "post", $res = "json")
    {
        $curl = curl_init();
        $this_header = ["charset=UTF-8"];
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $this_header);
        if($type == "post") {
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        }
        $output = curl_exec($curl);
        curl_close($curl);
        if($res == "json") {
            return json_decode($output, true);
        }
        return $output;
    }
    public static function https_request_file($url, $data = "", $type = "post")
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        if($type == "post") {
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        }
        $output = curl_exec($curl);
        header("Content-type: application/octet-stream");
        header("Content-Disposition: attachment; filename=原文出证" . time() . ".pdf");
        echo $output;
        curl_close($curl);
    }
    public function base64EncodeImage($image_file)
    {
        $base64_image = "";
        $image_info = getimagesize($image_file);
        $image_data = fread(fopen($image_file, "r"), filesize($image_file));
        $base64_image = "data:" . $image_info["mime"] . ";base64," . chunk_split(base64_encode($image_data));
        return $base64_image;
    }
}

?>